package com.desktopmng.action;

import java.util.Properties;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 公用baseAction ，定义了常规方法，以及需要的request
 * 
 * @author Administrator
 * 
 */
public class BaseAction extends ActionSupport implements ServletRequestAware,
		ServletResponseAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected static final String ADDINFO = "addInfo";

	protected static final String SAVEINFO = "saveInfo";

	protected static final String DELINFO = "delInfo";

	protected static final String SEARCHINFOINIT = "searchinfoinit";

	protected static final String SEARCHINFO = "searchinfo";

	protected static final String MODIFYINFO = "modifyInfo";

	protected static final String ERROR = "error";

	protected static final String MSSAGE = "message";

	protected static final String VIEWINFO = "viewInfo";

	protected int pageSize;
	protected int pageNo;
	protected int pageStart;
	protected String sortCols;
	protected Properties queryProp = new Properties();

	protected HttpServletRequest request; // 新建一个request
	protected HttpServletResponse response;

	@Override
	public String execute() throws Exception {
		throw new UnsupportedOperationException(
				"Method Searchinfoinit() not yet implemented.");
	}

	/**
	 * 查询初始话
	 * 
	 * @return
	 * @throws Exception
	 */
	public String searchinfoinit() throws Exception {
		throw new UnsupportedOperationException(
				"Method Searchinfoinit() not yet implemented.");
	}

	/**
	 * 查询信息
	 * 
	 * @return
	 * @throws Exception
	 */
	public String searchinfo() throws Exception {
		throw new UnsupportedOperationException(
				"Method Searchinfo() not yet implemented.");
	}

	/**
	 * 新增信息初始化
	 * 
	 * @return
	 * @throws Exception
	 */
	public String addInfo() throws Exception {
		throw new UnsupportedOperationException(
				"Method addInfo() not yet implemented.");
	}

	/**
	 * 保存信息，包括新增保存和更新保存
	 * 
	 * @return
	 * @throws Exception
	 */
	public String saveInfo() throws Exception {
		throw new UnsupportedOperationException(
				"Method SaveInfo() not yet implemented.");
	}

	/**
	 * 修改信息初始化
	 * 
	 * @return
	 * @throws Exception
	 */
	public String modifyInfo() throws Exception {
		throw new UnsupportedOperationException(
				"Method ModifyInfo() not yet implemented.");
	}

	/**
	 * 查看信息
	 * 
	 * @return
	 * @throws Exception
	 */
	public String viewInfo() throws Exception {
		throw new UnsupportedOperationException(
				"Method ViewInfo() not yet implemented.");
	}

	/**
	 * 删除信息
	 * 
	 * @return
	 * @throws Exception
	 */
	public String delInfo() throws Exception {
		throw new UnsupportedOperationException(
				"Method DelInfo() not yet implemented.");
	}

	
	public void setServletRequest(HttpServletRequest request) {
		this.request = request; // 得到可以使用的request
	}

	/**
	 * 获取ResourceTarget链接
	 * 
	 * @param request
	 * @return
	 */
	protected String getResourceTargetUrl(String url) {
		String resourceTarget = "";
		int index = url.lastIndexOf("/");
		if (index > 0) {
			resourceTarget = url.substring(index, url.length());
		}
		return resourceTarget;
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response;

	}

}
